package com.apexwear.apexutils.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.NonNull;

import com.apexwear.apexutils.R;
import com.apexwear.apexutils.api.OnPositiveClickListener;

public class DisconnectHintDialog extends Dialog {
    OnPositiveClickListener onPositiveClickListener;
    Context mContext;

    public DisconnectHintDialog(@NonNull Context context, OnPositiveClickListener onPositiveClickListener) {
        super(context, R.style.waiteDialog);
        mContext = context;
        this.onPositiveClickListener = onPositiveClickListener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_disconnect_message, null, false);
        setContentView(dialogView);
        setCancelable(true);
        setCanceledOnTouchOutside(true);
        dialogView.findViewById(R.id.confirm_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (onPositiveClickListener != null) {
                    onPositiveClickListener.clickButton(null);
                }
            }
        });
        dialogView.findViewById(R.id.cancel_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    public void destroyDialog() {
        mContext = null;
        onPositiveClickListener = null;

    }
}
